package com.ram.controller;

import com.ram.pojo.AssetAttachment;
import com.ram.pojo.Result;
import com.ram.service.AssetAttachmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/asset/attachment")
public class AssetAttachmentController {
    @Autowired
    private AssetAttachmentService attachmentService;

    @GetMapping("/list")
    public Result list(@RequestParam Integer assetId) {
        return Result.success(attachmentService.list(assetId));
    }

    @GetMapping("/{id}")
    public Result getById(@PathVariable Integer id) {
        return Result.success(attachmentService.getById(id));
    }

    @PostMapping
    public Result add(@RequestBody AssetAttachment attachment) {
        attachmentService.add(attachment);
        return Result.success();
    }

    @DeleteMapping("/{id}")
    public Result delete(@PathVariable Integer id) {
        attachmentService.deleteById(id);
        return Result.success();
    }
} 